home *** CD-ROM | disk | FTP | other *** search
- Path: thor.tu.hac.com!collins
- From: collins@thor.tu.hac.com (Ron Collins)
- Newsgroups: comp.lang.c
- Subject: Re: Can main() function be called?
- Date: 7 Feb 1996 23:45:38 GMT
- Organization: Advanced Depot Systems
- Message-ID: <4fbdj2$dmb@hacgate2.hac.com>
- References: <823183263.118@fountain.demon.co.uk> <4f1mv0$2fd@cloner4.netcom.com> <4f6n77$e53@library.erc.clarkson.edu>
- NNTP-Posting-Host: thor.tu.hac.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Mountain (jimbo) (koglerje@craft.camp.clarkson.edu) wrote:
- : Mike Rosenblyum (rozen@ix.netcom.com) wrote:
- : : I think that it cannot be done, I see no reasonalbe way how main()
- : : could be called more than once.
-
-
- : : What is your thoughts on this?
-
-
- : Sure you can call main() again, well kindof, just uses setjmp()
- : and longjmp() just put a setjump() call inside main() like:
-
- : int main()
- : {
- : setjmp(jmp_buf hi);
- : ..
- : }
-
- : then when you want to "run main()" again, just call longjmp(jmp_buff hi, int i);
- : you will have to look up the specifics but this is standard across the platforms. the real question is WHY would you want to do this??????
-
- : hope i was of some assistance.
- : jimbo
- : koglerje@wckn.dorm
-
-
- "main()" is a function like any other function. The only thing special about
- it is that the name "main" is called by the C startup code. But the
- startup code only calls it once (at the start of the program, obviously).
- You are free to call "main()" as often as you like.
-
- -- collins --
-